package com.ikas.ai.framework.statistics.function;

import com.ikas.ai.framework.statistics.StatisticType;

import java.util.List;
import java.util.Objects;

/**
 * @Description: 计算空值数量
 * @Author: qi.yilai
 * @Date: 2023/10/27 17:37
 * @Version: 1.0.0
 **/
public class NullCountCalcFunction implements CalcFunction<List, Object, Object, Long> {
    @Override
    public Long calculate(List list) {
        return list.stream().filter(Objects::isNull).count();
    }

    @Override
    public Long calculate(List list, Object o1, Object o2) {
        throw new UnsupportedOperationException("不支持利用临时变量简化计算");
    }

    @Override
    public StatisticType type() {
        return StatisticType.NULL_COUNT;
    }
}
